package org.example;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.example.dto.OrderPlacedEvent;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.kafka.annotation.KafkaListener;

@SpringBootApplication
@EnableDiscoveryClient
@Slf4j
public class NotificationServiceApp
{
    public static void main( String[] args )
    {
        SpringApplication.run(NotificationServiceApp.class,args);
    }
    @KafkaListener(topics = "notTopic")
    public void handler(OrderPlacedEvent event){               //接收消息
        log.info("收到消息：{},{}",event.getOrderNumber(), JSON.toJSONString(event));
    }
}
